package org.meetunexpectedly.entity.video;

import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.meetunexpectedly.entity.BaseEntity;

import javax.validation.constraints.NotBlank;
import java.util.Arrays;
import java.util.List;

/**
 * @Description: 分类表
 * @Author: pupil
 * @Date: 2024/08/13 下午 6:24
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class Type extends BaseEntity {
    private static final long serialVersionUID = 1L;

    @NotBlank(message = "分类名称不可为空")
    private String name; // 类型名称

    private String description; // 描述

    private String icon; // 图标

    private Boolean open; // 状态  0 为开启，1为关闭

    private String labelNames; // 标签名  标签名可能有多个，通过逗号分隔

    private Integer sort; // 排序

    @TableField(exist = false)
    private Boolean used; // 记录用户是否订阅该类型


    // 获取该类型的所以标签名
    public List<String> buildLabels() {
        return Arrays.asList(labelNames.split(","));
    }
}
